﻿using Lidgren.Network;
using System;
namespace BattleFury.Lib.Network.Packets
{
    [Serializable]
    public class MessagePacket : IPacket
    {
        PacketCommand IPacket.Command { get { return PacketCommand.Message; } }
        NetDeliveryMethod IPacket.NetDeliveryMethod { get { return NetDeliveryMethod.Unreliable; } }
        long IPacket.ServerTime
        {
            get { return _servertime; }
        }

        private readonly long _servertime;
        public string Message = string.Empty;

        public MessagePacket() { }
        public MessagePacket(NetIncomingMessage msg)
        {
            Message = msg.ReadString();
            _servertime = msg.ReadInt64();
        }

        NetOutgoingMessage IPacket.ToOutgoingMessage(NetClient client)
        {
            NetOutgoingMessage msg = client.CreateMessage();
            msg.Write((int)((IPacket)this).Command);
            msg.Write(Message);
            msg.Write(_servertime);
            return msg;
        }



    }
}